package com.fyzk.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.fyzk.activity.lottery.recommend_order.MainDialogBean;
import com.fyzk.activity.share.ShareTuijianActivity;
import com.fyzk.bean.RechargeBean;
import com.fyzk.data.preference.MySharedPreferences;
import com.tyjc.lottery.R;

import http.DataUtil.text.TextUtil;

/**
 * <p>
 *
 * @author 指尖沙漏
 * @mood
 * @description
 * @date 2019/6/10 17:13
 * </p>
 */
public class MainDialog extends Dialog implements View.OnClickListener {
    private Context mContext;
    private TextView contentTextView;
    private TextView submitTxt;
    private ImageView cancel;
    private MainDialogBean mainDialogBean;


    public MainDialog(Context context, MainDialogBean mainDialogBean) {
        super(context, R.style.commonDialog);
        this.mContext = context;
        this.mainDialogBean = mainDialogBean;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_dialog);
        setCanceledOnTouchOutside(false);
        initView();
    }

    private void initView() {
        contentTextView = findViewById(R.id.text_content);
        submitTxt = findViewById(R.id.submit);
        cancel = findViewById(R.id.cancel);
        submitTxt.setOnClickListener(this);
        cancel.setOnClickListener(this);
        if (mainDialogBean != null) {
            String content = mainDialogBean.getContent()
                    .replaceAll("\\\\n", "\r\n")
                    .replaceAll("\\n", "\r\n");
            contentTextView.setText(content);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.submit:
                MySharedPreferences.getInstance().saveDialogDate();
                dismiss();
                break;
            case R.id.cancel:
                dismiss();
                break;
        }
    }

}
